﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using CustomsSystem.BLL;
using CustomsSystem.Model;

namespace WEB.score
{
    public partial class scoreView : System.Web.UI.Page
    {
        public DataSet ds;
        protected void Page_Load(object sender, EventArgs e)
        {
            gvScore.Attributes.Add("style", "word-break:keep-all;word-wrap:normal");
            if (!Page.IsPostBack)
            {
                ScoreManage scoreManage = new ScoreManage();
                ds = scoreManage.GetList("");
                gvScore.DataSource = ds;
                gvScore.DataBind();
            }
        }
        protected void gvScore_RowEditing(object sender, GridViewEditEventArgs e)
        {
            int id = Convert.ToInt32(gvScore.DataKeys[e.NewEditIndex].Value);
            Response.Redirect("scoreHandle.aspx?ID=" + id);
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            string strQuery = ddlQuery.SelectedValue;
            ScoreManage scoreManage = new ScoreManage();
            string strSql = "";
            switch (ddlQuery.SelectedIndex)
            {
                case 0:
                    strSql = string.Format("{0} = '{1}'", strQuery, tbQuery.Text);
                    break;
                case 1:
                    strSql = string.Format("{0} like '%{1}%'", strQuery, tbQuery.Text);
                    break;
            }
            DataSet ds = new DataSet();
            ds = scoreManage.GetList(strSql);
            gvScore.DataSource = ds;
            gvScore.DataBind();
        }

        /// <summary>
        /// 网页跳转
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvScore_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string index = e.CommandArgument.ToString(); //那行被选中,取出选中行的索引 
            if (e.CommandName == "sheetID")
            {
                int id = Convert.ToInt32(gvScore.DataKeys[int.Parse(index)].Value);
                Response.Redirect("~/Client/sheetDetails1.aspx?ID=" + id);
            }
            if (e.CommandName == "Reply")
            {
                int id = Convert.ToInt32(gvScore.DataKeys[int.Parse(index)].Value);
                Response.Redirect("~/score/scoreHandle.aspx?ID=" + id);
            }
        }
    }
}